﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WI.CandidateManager.Common.Data.Entities;

namespace WI.CandidateManager.Business.Objects
{
    /// <summary>
    /// Logic for working with Tasks: creating, editing, deleting etc.
    /// </summary>
    public class TaskBO: BOBase
    {
        /// <summary>
        /// Getting list of tasks (all types of tasks)
        /// </summary>
        /// <returns>List of tasks</returns>
        public List<TaskBase> GetTaskList()
        {
            return DataContext.TaskBaseSet.ToList<TaskBase>();
        }

        /// <summary>
        /// Create new task and add it to DataBase.
        /// </summary>
        /// <param name="test">object of Test from controller.</param>
        /// <returns>true if creating was succesful and false if it wasn't.</returns>
        public bool CreateNewTest(Test test)
        {
            try
            {
                DataContext.TestSet.Add(test);
                DataContext.SaveChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
